package org.ragdollcat.first.service;

import cn.hutool.http.server.HttpServerRequest;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.ragdollcat.first.common.BaseResponse;
import org.ragdollcat.first.model.dto.user.UserQueryRequest;
import org.ragdollcat.first.model.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import org.ragdollcat.first.model.vo.LoginUserVO;
import org.ragdollcat.first.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 86158
* @description 针对表【user(用户)】的数据库操作Service
* @createDate 2025-08-11 21:38:54
*/
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @param account
     * @param password
     * @param rePassword
     * @return
     */
    BaseResponse<?> userRegister(String account,String password,String rePassword);

    /**
     * 用户登录
     * @param account
     * @param password
     * @param httpServerRequest
     * @return
     */
    BaseResponse<LoginUserVO> userLogin(String account, String password, HttpServletRequest httpServerRequest);

    LoginUserVO castUserToLoginUserVO(User user);

    /**
     * 获取当前登录用户
     * @param httpServerRequest
     * @return
     */
    User getLoginUser(HttpServletRequest httpServerRequest);

    /**
     * 退出登录
     * @param request
     */
    void userLoginout(HttpServletRequest request);

    String passwordEncryption(String password);

    /**
     * 单个用户信息脱敏
     * @param user
     * @return
     */
    UserVO castUserToUserVo(User user);

    /**
     * 得到Mybatisplus 的用户查询条件
     * @param userQueryRequest
     * @return
     */
    Wrapper<User> getUserQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 批量用户信息脱敏
     * @param records
     * @return
     */
    List<UserVO> castUsersToUserVos(List<User> records);

    /**
     * 是否是管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(User user);
}
